/*
 * @Author: hrg
 * @Date: 2023-05-17 14:58:16
 * @LastEditTime: 2023-05-18 14:50:52
 * @FilePath: \study_go\study04\demo\main.go
 * @Description:
 */

package main

import (
	"fmt"
)

func main() {
	a := make(map[int]string)
	a[100] = "hrg"
	a[111] = "hyy"

	// 获取长度：
	fmt.Println(len(a))

	//遍历映射，只能通过for range
	for k, v := range a {
		fmt.Printf("key:%v,value:%v\n", k, v)
	}

	// 增加难度的遍历：
	school := make(map[string]map[int]string)
	school["class1"] = make(map[int]string)
	school["class1"][1101] = "hrg1"
	school["class1"][1102] = "hrg2"
	school["class1"][1103] = "hrg3"

	school["class2"] = make(map[int]string)
	school["class2"][1201] = "hyy1"
	school["class2"][1202] = "hyy2"
	school["class2"][1203] = "hyy3"

	fmt.Println(school)
	//循环遍历school  通过for range循环
	for k1, v1 := range school {
		fmt.Println("k1", k1)
		for k2, v2 := range v1 {
			fmt.Printf("key:%v,value:%v\t", k2, v2)
		}
		fmt.Println()
	}

}
